

class Section
  @imgDir 
  @doc
  
  def initialize(doc, title, text=nil, chart=nil)
    @doc = doc
    @title = title
    @text = text
    @chart = chart
  end
  
  def to_html
    s = "<h1>#{@title}</h1>"
    s = s + "<p>"
    s = s + @text + "<br/>" unless @text.nil?
    
    unless @chart.nil?
      filename = self.hash.to_s + ".png"
      dir = "#{@doc.directory}/img"
      Dir.mkdir(dir) unless File.directory?(dir)  
      @chart.write("#{dir}/#{filename}")
      s = s + "<img src=\"img/#{filename}\"/>"
    end
    
    s += "</p>"
    s
  end
end